//
//  ProgressTableViewAdapter.m
//  EducationOID
//
//  Created by slz on 2017/8/4.
//  Copyright © 2017年 bnsr. All rights reserved.
//

#import "ProgressTableViewAdapter.h"
#import "ProgressListModel.h"
#import "ProgressItem.h"
#import "ProgressTableViewCell.h"
#import "UIView+XIB.h"
#import "ProgressDetailViewController.h"

@implementation ProgressTableViewAdapter

- (TGMBaseModelActionData*)actionDataForRequestModelData:(MFWDataRequestType)type
{
    return [[ProgressListModel managedModelInstance] actionData];
}


- (CGFloat)model2UITableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}


- (UITableViewCell *)model2UITableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ProgressItem * item = self.listData[indexPath.row];
    static NSString *bannerIdentifier = @"OIPubListTableViewCell";
    ProgressTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:bannerIdentifier];
    
    if(cell == nil)
    {
        cell = [ProgressTableViewCell instanceWithNibName:@"ProgressTableViewCell" owner:nil];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.codeLabel.text = item.oid_code;
    cell.stateLabel.text = [self stateWithNumber:[item.status integerValue]] ;
    return cell;
}

- (NSString *)stateWithNumber:(NSInteger)number{
    NSString * string = @"unknow";
    switch (number) {
        case 1:
            string = @"完成提交申请";
            break;
        case 2:
            string = @"完成审核";
            break;
        case 3:
            string = @"公示中";
            break;
        case 4:
            string = @"完成发布";
            break;
        case 5:
            string = @"审核未通过";
            break;
        default:
            string = @"unknow";
            break;
    }
    return string;
}

- (BOOL)model2UITableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    ProgressItem * item = self.listData[indexPath.row];
    ProgressDetailViewController * detailController = [[ProgressDetailViewController alloc]init];
    detailController.oid = item.pId;
    [self.contextViewController.navigationController pushViewController:detailController animated:YES];
    return YES;
}

-(BOOL)supportPullRefreshHeader{
    return NO;
}


@end
